
	mui.init({
				pullRefresh: {
					container: '#pullrefresh',
					up: {
						auto:false,
						contentrefresh: '正在加载...',
						callback: pullupRefresh
					}
				}
	});
	
	
	var userinfo = app.getState() || {};
    var uid = userinfo.user_id;
    var currenPage=1;
    var pageSize=10;
    var total_page=0;
    var total_count=0;
    
    window.onload = function(){
    	mui.ajax({
				url: apiurl + "Shift/shift_log/",
				data: {user_id:uid,'p':currenPage,'size':pageSize,'_token':userinfo.token},
				async: true,
				dataType: 'json',
				crossDomain: true, //强制使用5+跨域
				type: 'get',
				timeout: 10000,
				success: function(res) {
					console.log(JSON.stringify(res));
					// 请求成功
					if(res.status ==-3){
						mui.toast(res.msg);
						app.out();
						return false;
					} else {
						total_page=res.total_page;
						total_count=res.sum;
						var htm=get_data(res.resource);
						$('#pullrefresh .mui-scroll ul').append(htm);
					}
				},
				error: function(xhr, type, errorThrown) {
					//console.log(JSON.stringify(xhr));
					//console.log(JSON.stringify(type));
					//console.log(JSON.stringify(errorThrown));
					mui.toast('获取数据失败！');
				}
			});
			
			 mui.plusReady(function(){
			    //关闭等待框
			    plus.nativeUI.closeWaiting();
			    //显示当前页面
			    mui.currentWebview.show();
			});

    }

    function get_data(data){
    	var htm='';
		for(i in data) {
			/*
			 * <li>
						<div>
							<span class="cqxf-time">2019-03-05 12:12:12</span>
							<span class="cqxf-balance">8.00000</span>
						</div>
						<span class="ads">来自<font>dsafbihefuehwuifhu3njnsc</font>的转账</span>
					</li>
			 */
			htm += '<li>';
			htm += '<div>';
			htm += '<span class="cqxf-time">'+data[i]['add_time']+'</span>';
			htm += '<span class="cqxf-balance">'+data[i]['money']+'</span>';
			htm += '</div>';
			htm += '<span class="ads">来自<font>'+md5(data[i]['user_id'])+'</font>的转账</span>';
			htm += '</li>';
		}
		return htm;
    }

	var count = 0;
	function pullupRefresh() {
		setTimeout(function() {
			currenPage++;
			mui.ajax({
				url: apiurl + "Shift/shift_log/",
				data: {user_id:uid,'p':currenPage,'size':pageSize,'_token':userinfo.token},
				async: true,
				dataType: 'json',
				crossDomain: true, //强制使用5+跨域
				type: 'get',
				timeout: 10000,
				success: function(res) {
					console.log(JSON.stringify(res));
					// 请求成功
					if(res.status ==-3){
						mui.toast(res.msg);
						app.out();
						return false;
					} else {
						var htm=get_data(res.resource);
						$('#pullrefresh .mui-scroll ul').append(htm);
					}
					/*
					if(currenPage>total_page || total_count<=$('#pullrefresh .mui-scroll ul li').length){
						mui('#pullrefresh').pullRefresh().endPullupToRefresh(true); //参数为true代表没有更多数据了。
					    return false;
					}*/
					if(currenPage < total_page){
	                    mui('#pullrefresh').pullRefresh().endPullupToRefresh(false);    /*能上拉*/
	                }else{
	                    mui('#pullrefresh').pullRefresh().endPullupToRefresh(true);/*不能上拉*/
	                }
				},
				error: function(xhr, type, errorThrown) {
					//console.log(JSON.stringify(xhr));
					//console.log(JSON.stringify(type));
					//console.log(JSON.stringify(errorThrown));
					mui.toast('获取数据失败！');
				}
			});
			
		}, 1500);
	}
	
